// clean-this-file
.underline-hover {
	display: initial;
}
.hide-form-sidebar {
	.form-sidebar {
		display: none !important;
	}
}

.sidebar-padding {
	padding: 12px 14px;
}

body[data-route=""] .main-menu,
body[data-route="desk"] .main-menu {
	@extend .hide-form-sidebar;
}

body[data-route^="List"] .main-menu {
	.list-sidebar {
		display: block !important;
	}

	@extend .hide-form-sidebar;
}

body[data-route^="Module"] .main-menu {
	.module-sidebar {
		display: block !important;
	}

	@extend .hide-form-sidebar;
}

body {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	align-items: flex-start;
	justify-content: flex-start;
	position: relative;
}

.main-section {
	width: 100%;
	height: 100vh;
	overflow: scroll;
	overflow-x: hidden;
	overflow-y: visible;
}
.body-sidebar-container {
	display: flex;
	flex-direction: column;
	height: fit-content;
	width: fit-content;

	.body-sidebar-placeholder {
		display: none;
		width: 53px;
		height: 100vh;
	}
}

.body-sidebar {
	width: 53px;
	background: var(--subtle-accent);
	border: 1px solid var(--border-color);

	display: flex;
	flex-direction: column;
	justify-content: space-between;
	height: 100vh;
	z-index: 1030;

	.body-sidebar-top {
		display: flex;
		align-items: flex-start;
		flex-direction: column;
		flex-wrap: nowrap;

		gap: 2px;
		justify-content: flex-start;
		overflow: hidden;
		padding: 15px;
		position: static;
		font-size: var(--text-base);
		// transition: width 200ms;
	}

	.body-sidebar-bottom {
		padding: 15px;
	}

	.app-logo {
		width: 21px;
	}

	.sidebar-items {
		width: 100%;
	}

	.divider {
		margin: var(--margin-xs) 0;
		border-top: 1px solid var(--border-color);
	}

	.standard-sidebar-section {
		margin-bottom: var(--margin-xl);

		&:last-of-type {
			margin-bottom: var(--margin-sm);
		}

		&:first-child {
			margin-top: 24px;
		}
	}

	.standard-sidebar-item {
		display: flex;
		justify-content: space-between;
		padding: 0px;

		.sidebar-item-control {
			display: none;

			> * {
				align-self: center;
				margin-left: 3px;
				box-shadow: none;
			}

			.drop-icon {
				padding: 0px 12px 0px 2px;
			}

			svg {
				margin-right: 0;
				margin-top: 3px;
			}
		}

		.sidebar-item-label {
			display: none;
		}

		.item-anchor {
			display: flex;
			overflow: hidden;
			gap: 5px;
			align-items: center;
			padding: 3px 0px 3px 11px;
			flex: 1;

			&:hover {
				text-decoration: none !important;
			}
		}
	}

	.edit-sidebar-link {
		display: none;
	}

	.sidebar-item-container {
		position: relative;
		margin-left: -10px;
		margin-bottom: 6px;

		/* nested container */
		.sidebar-item-container {
			margin-left: 20px;

			.standard-sidebar-item {
				justify-content: start;
			}
		}

		.indicator {
			margin-left: 5px;
		}
	}
}

@mixin body-sidebar-expanded {
	.body-sidebar {
		// make it an overlay on hover
		position: absolute;
		width: 200px;

		.body-sidebar-top {
			overflow-y: auto;
		}
		.sidebar-item-label {
			display: flex;
		}
		.sidebar-item-control {
			display: block;
		}
		.edit-sidebar-link {
			display: block;
		}
	}

	// show placeholder so that main section remains static
	.body-sidebar-placeholder {
		display: flex;
	}
}

.body-sidebar-container.expanded {
	@include body-sidebar-expanded();
}

@include media-breakpoint-down(sm) {
	// body sidebar hidded in mobile view
	.body-sidebar-container {
		.body-sidebar {
			width: 0px;
			overflow: hidden;
		}
	}

	// expands when navbar-brand is clicked
	.body-sidebar-container.expanded {
		.body-sidebar {
			width: 200px;
		}
	}
}

@include media-breakpoint-up(sm) {
	// for bigger screens, expand / collapse on hover
	.body-sidebar-container:hover {
		@include body-sidebar-expanded();
	}
}

.app-switcher-dropdown {
	.sidebar-item-control {
		margin-top: -2px;
	}
}

.app-switcher-menu {
	position: absolute;
	top: 44px;
	left: 7px;
	width: 183px; /* 200 - 7px */
	padding: var(--padding-xs);
	box-shadow: var(--shadow-base);
	background-color: var(--neutral);
	z-index: 1;
	border-radius: var(--border-radius-tiny);
}

.app-item {
	padding: var(--padding-xs);
	border-radius: var(--border-radius-tiny);

	&:hover {
		background-color: var(--subtle-accent);
	}

	a {
		text-decoration: none;
		display: flex;
		align-items: center;
	}
}

// form sidebar
.form-sidebar {
	.sidebar-section {
		.form-sidebar-items {
			display: flex;
			width: 100%;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			color: var(--text-light);

			.icon-btn {
				height: unset;
			}

			a {
				color: var(--text-light);
			}
		}
	}

	.form-tags {
		.tag-area {
			margin-top: -3px;
			margin-left: -4px;
		}

		input {
			color: $text-color !important;
			font-style: italic;
		}

		.tagit-new {
			clear: both;
			margin-top: 2px;
			margin-bottom: -1px;
		}
	}

	a.close {
		position: absolute;
		right: 5px;
	}

	.form-sidebar-stats {
		li:first-child {
			@include flex(flex, space-between, center, null);

			use.comment-icon {
				fill: var(--gray-500);
			}
		}
	}

	hr {
		margin: 15px -15px;
	}

	.sidebar-image-section {
		width: min(100%, 220px);
		cursor: pointer;

		.sidebar-image {
			height: auto;
			max-height: 220px;
			object-fit: cover;
		}

		.standard-image {
			font-size: 52px;
			border-radius: var(--border-radius-lg);
		}

		.sidebar-image-wrapper {
			position: relative;
		}

		.sidebar-image,
		.sidebar-standard-image {
			transition: opacity 0.3s;
			border-radius: var(--border-radius-lg);
			border: 1px solid var(--border-color);
		}

		.sidebar-image-wrapper:hover {
			.sidebar-image,
			.sidebar-standard-image {
				opacity: 0.5;
			}
			.sidebar-image-actions {
				display: block;
			}
		}
		.sidebar-image-actions {
			display: none;
			position: absolute;
			top: 50%;
			right: 0;
			left: 0;
			transform: translateY(-50%);
			text-align: center;
			z-index: 1;
		}
		// TODO: find better fix
		.sidebar-standard-image {
			.standard-image {
				height: 0;
				padding: 50% 0;
			}
		}
	}
}

.layout-side-section {
	@include get_textstyle("sm", "regular");
	// padding-right: 30px;
	width: 220px;
	border-left: 1px solid var(--border-color);

	.sidebar-section {
		padding: var(--padding-md);
		border-bottom: 1px solid var(--border-color);
	}

	.sidebar-section:last-child {
		border-bottom: none;
	}

	&.hide-sidebar {
		display: none;
	}

	> .divider {
		display: none !important;
	}

	.sidebar-menu > li > a {
		display: inline-block;
		&:hover,
		&:focus,
		&:active {
			@extend .underline-hover;
		}
	}

	.sidebar-label {
		font-weight: var(--weight-medium);
		color: var(--heading-color);
		display: flex;
		align-items: center;
		cursor: pointer;

		.es-icon {
			margin-right: 4px;
		}

		.icon {
			margin: 0;
			margin-right: var(--margin-xs);
			--icon-stroke: var(--text-muted);
		}
	}

	.form-sidebar {
		.modified-by,
		.created-by,
		.pageview-count {
			@include get_textstyle("sm", "regular");
		}

		.modified-by,
		.pageview-count {
			margin-bottom: var(--margin-md);
		}
	}

	.overlay-sidebar {
		@media (max-width: 991px) {
			margin-top: 0 !important;
			position: fixed;
			background: var(--fg-color);
			top: 0;
			left: 0;
			transform: translateX(-110%);
			z-index: 1300;
			box-shadow: var(--shadow-base);
			height: 100%;
			width: 40%;
			display: block !important;
			transition: transform 200ms ease-in-out;

			&.opened {
				transform: translateX(0);
				overflow-y: auto;
			}

			.divider {
				height: 1px;
				background-color: var(--border-color);
				opacity: 0.7;
			}
		}

		@media (max-width: 767px) {
			width: 60%;
		}
	}

	div.close-sidebar {
		position: fixed;
		top: 0;
		right: 0;
		opacity: 0.3;
		background: #000;
		z-index: 1100;
		height: 100%;
		width: 100%;
	}

	.module-sidebar-nav {
		margin-top: 15px;
		@media (max-width: 991px) {
			padding-left: 0;
			padding-right: 0;

			.module-link {
				padding: 15px 15px 15px 25px;
			}
		}
	}
}

.overlay-sidebar {
	ul.dropdown-menu {
		li {
			padding: 0 !important;
		}

		.badge {
			top: 0;
			right: 0;
		}
	}
}

.list-sidebar {
	.sidebar-section a {
		font-size: var(--text-xs);
	}

	.list-link {
		margin-top: var(--margin-md);
	}

	.list-sidebar-button {
		display: flex;
		justify-content: space-between;
		padding: 4px 8px;
		color: var(--text-muted);

		&:hover {
			text-decoration: none;
		}
	}

	.group-by-count {
		position: relative;
	}

	.group-by-value {
		width: 90%;
	}

	.dropdown-menu {
		max-height: 300px;
		overflow-y: auto;
		min-width: 180px;
		max-width: 220px;
		z-index: 100;

		.dropdown-item {
			display: flex;
			justify-content: space-between;
			position: relative;
			&:hover {
				text-decoration: none;
			}
			.applied {
				position: absolute;
				left: 10px;
				.icon use {
					stroke-width: 2;
				}
			}
		}
		.empty-state {
			padding: 10px 15px;
			text-align: center;
			color: $text-muted;
		}
	}

	.dropdown-menu.has-selected {
		.dropdown-item {
			padding-left: var(--padding-xl);
			padding-right: var(--padding-md);
		}
	}

	.dropdown-search {
		padding: 8px;
	}

	.stat-no-records {
		margin: 5px 10px;
	}

	.sidebar-action {
		@include get_textstyle("sm", "regular");
		color: var(--primary);
		margin-top: 10px;
	}

	.list-filters {
		.clearfix {
			display: none;
		}

		input:not([data-fieldtype="Check"]) {
			background: var(--control-bg-on-gray);
		}

		.filter-pill {
			display: flex;
			justify-content: space-between;

			.filter-name {
				width: 90%;
				text-align: left;
			}
		}
	}
}

.filters-search {
	margin-bottom: 10px;
}

.attachment-row,
.form-tag-row {
	margin: var(--margin-xs) 0;
	max-width: 100%;
	.data-pill {
		@include get_textstyle("sm", "regular");
		justify-content: space-between;
		box-shadow: none;
		line-height: 1;
	}
}
.attachment-row {
	.data-pill {
		background-color: unset;
		box-shadow: none;
		padding: 0 var(--padding-xs) 0 var(--padding-md) !important;

		.attachment-file-label {
			width: 94px;
			display: block;
			margin-left: var(--margin-xs);
		}
	}
}

.form-tag-row {
	margin-right: var(--margin-xs);
	.data-pill {
		background-color: var(--subtle-fg);
	}
	display: inline-flex;
}

.explore-link {
	margin-top: var(--margin-sm);
}

.attachments-actions {
	gap: 6px;
}

.show-all-btn {
	--icon-stroke: var(--text-light);
	width: 100%;
	background-color: var(--bg-color);
	text-align: start;
	margin-top: var(--margin-sm);
	margin-left: var(--margin-md);
	margin-bottom: var(--margin-sm);
	color: var(--text-light);
}

.form-assignments,
.form-shared {
	.assignments,
	.shares {
		margin: var(--margin-xs) 0px;
	}
}
.add-assignment-btn,
.add-attachment-btn,
.add-review-btn,
.shares,
.add-tags-btn,
.share-doc-btn,
.followed-by {
	max-width: 100%;
	display: block;
	width: unset;
	height: unset;
	margin-right: 0;
	padding: var(--padding-xs) !important;
	border-radius: var(--border-radius-full);
	&:hover {
		background-color: var(--subtle-fg);
	}
	&:focus {
		box-shadow: none;
	}
}

.form-reviews {
	.reviews {
		display: flex;
		flex-wrap: wrap;
	}
	.review {
		display: flex;
		font-weight: 500;
		height: 28px;
		border-radius: 14px;
		font-size: var(--text-xs);
		margin-bottom: var(--margin-sm);
		margin-right: var(--margin-xs);
		border: 1px solid var(--dark-border-color);
		padding: 2px 3px;
		align-items: center;
		min-width: 60px;
		background: var(--fg-color);
		.avatar {
			width: 20px;
			height: 20px;
		}
		.review-points {
			margin-left: 3px;
			flex: 1;
			text-align: center;
		}
	}
}

.review-popover {
	padding: 0px;
	min-width: 200px;
	max-width: 250px;

	.popover-body,
	.popover-content {
		padding: 0;
	}
	.body {
		border-bottom: 1px solid $border-color;
	}

	.subject,
	.body {
		padding: var(--padding-sm);
		overflow-wrap: break-word;
		p {
			margin-top: var(--margin-xs);
			margin-bottom: 0px;
		}
	}
}

.liked-by-popover {
	.popover-body {
		min-height: 30px;
		padding: 0px;

		ul.list-unstyled {
			margin-bottom: 0px;

			li {
				padding: var(--padding-xs) var(--padding-sm);
				margin: 2px;

				&:hover {
					background-color: var(--fg-hover-color);
				}
			}
		}
	}
}

.tags-input {
	margin-bottom: var(--margin-sm);
	font-size: var(--text-xs);
	background: inherit;
	border: none;
	outline: none;
}

.tags-placeholder {
	margin-bottom: var(--margin-sm);
	display: inline-block;
	@include get_textstyle("sm", "regular");
}

.shared-user {
	margin-bottom: 10px;
}
